#pragma once
#include "stdafx.h"
#include <atlbase.h>
#include <atlcoll.h>
#include <Sensorsapi.h>
#include <sensors.h>
#include <SensAPI.h>
#include <initguid.h>
#include <propkeydef.h>
#include <comutil.h>

class CSensorManagerEvents: public ISensorManagerEvents
{
public:

	CSensorManagerEvents(void);
//	CSensorManagerEvents(CSensorEvents *CSensorEvents);
	~CSensorManagerEvents(void);

	// These three methods are for IUnknown
	STDMETHOD(QueryInterface)(REFIID riid, void** ppObject );
	ULONG _stdcall AddRef();
	ULONG _stdcall Release();

	HRESULT Initialize();
	HRESULT Uninitialize();
	STDMETHOD(OnSensorEnter)(ISensor* pSensor, SensorState state);
	HRESULT RemoveSensor(REFSENSOR_ID sensorID);

private:
	// Member variable to implement IUnknown reference count
	LONG m_lRefCount;

	// Helper functions
	HRESULT AddSensor(ISensor* pSensor);
	HRESULT RemoveSensor(ISensor* pSensor);

	CSensorEvents *m_pSensorEvents;
	CComPtr<ISensorManager> m_spISensorManager; // Sensor Events class used for event sinking
	CAtlMap<SENSOR_ID, ISensor*> m_Sensors;           // Map to store sensors for life of class
};

